package com.wss.day07.exception;

/**
 * @author wangshaoshuai
 * @desc TODO
 * @date 2025/4/28
 */
public class ExceptionTest {
    private String id;
    private double balance;

    public ExceptionTest(String id, double balance) {
        this.id = id;
        this.balance = balance;
    }

    public void withdraw(double amount) throws InsufficientBalanceException {
        if (amount > balance) {
            throw new InsufficientBalanceException("余额不足，无法完成取款操作");
        }
        balance -= amount;
        System.out.println("取款成功，取出金额：" + amount);
    }

    public double getBalance() {
        return balance;
    }
}
